package cn.javadog.smartbreeding.web.controller;

import cn.javadog.smartbreeding.core.dto.PageDTO;
import cn.javadog.smartbreeding.core.dto.TemperatureRecordDTO;
import cn.javadog.smartbreeding.core.service.TemperatureRecordService;
import cn.javadog.smartbreeding.core.vo.PageVo;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import com.alibaba.dubbo.config.annotation.Reference;

/**
 * @author 余勇
 */
@Controller
@RequestMapping("temperature/record")
public class TemperatureRecordWebController {

	@Reference
	private TemperatureRecordService temperatureRecordService;

	@GetMapping("list")
	public String list(PageDTO dto, Model model){
		dto.setPageNo(1);
		dto.setPageSize(5);
		PageVo page = temperatureRecordService.list(dto);
		model.addAttribute("records", page.getRecords());
		return "statistics/temperature/list";
	}

	@PostMapping("add")
	public String add(@RequestBody TemperatureRecordDTO dto){
		temperatureRecordService.save(dto);
		return "statistics/temperature/add";
	}

}
